1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module sourceview.IndenterIF; 26 27 private import gobject.ObjectG; 28 private import gtk.TextIter; 29 private import sourceview.View; 30 private import sourceview.c.functions; 31 public import sourceview.c.types; 32 33 34 /** 35 * Auto-indentation interface. 36 * 37 * By default, [class@View] can auto-indent as you type when 38 * [property@View:auto-indent] is enabled. The indentation simply copies the 39 * previous lines indentation. 40 * 41 * This can be changed by implementing `GtkSourceIndenter` and setting the 42 * [property@View:indenter] property. 43 * 44 * Implementors of this interface should implement both 45 * [vfunc@Indenter.is_trigger] and [vfunc@Indenter.indent]. 46 * 47 * [vfunc@Indenter.is_trigger] is called upon key-press to 48 * determine of the key press should trigger an indentation. The default 49 * implementation of the interface checks to see if the key was 50 * [const@Gdk.KEY_Return] or [const@Gdk.KEY_KP_Enter] without %GDK_SHIFT_MASK set. 51 * 52 * [vfunc@Indenter.indent] is called after text has been 53 * inserted into [class@Buffer] when 54 * [vfunc@Indenter.is_trigger] returned %TRUE. The [struct@Gtk.TextIter] 55 * is placed directly after the inserted character or characters. 56 * 57 * It may be beneficial to move the insertion mark using 58 * [method@Gtk.TextBuffer.select_range] depending on how the indenter changes 59 * the indentation. 60 * 61 * All changes are encapsulated within a single user action so that the 62 * user may undo them using standard undo/redo accelerators. 63 */ 64 public interface IndenterIF{ 65 /** Get the main Gtk struct */ 66 public GtkSourceIndenter* getIndenterStruct(bool transferOwnership = false); 67 68 /** the main Gtk struct as a void* */ 69 protected void* getStruct(); 70 71 72 /** */ 73 public static GType getType() 74 { 75 return gtk_source_indenter_get_type(); 76 } 77 78 /** 79 * This function should be implemented to alter the indentation of text 80 * within the view. 81 * 82 * @view is provided so that the indenter may retrieve settings such as indentation and tab widths. 83 * 84 * @iter is the location where the indentation was requested. This typically 85 * is after having just inserted a newline (\n) character but can be other 86 * situations such as a manually requested indentation or reformatting. 87 * 88 * See [iface@Indenter.is_trigger] for how to trigger indentation on 89 * various characters inserted into the buffer. 90 * 91 * The implementor of this function is expected to keep @iter valid across 92 * calls to the function and should contain the location of the insert mark 93 * after calling this function. 94 * 95 * The default implementation for this virtual function will copy the 96 * indentation of the previous line. 97 * 98 * Params: 99 * view = a #GtkSourceView 100 * iter = the location of the indentation request 101 */ 102 public void indent(View view, ref TextIter iter); 103 104 /** 105 * This function is used to determine if a key pressed should cause the 106 * indenter to automatically indent. 107 * 108 * The default implementation of this virtual method will check to see 109 * if @keyval is [const@Gdk.KEY_Return] or [const@Gdk.KEY_KP_Enter] and @state does 110 * not have %GDK_SHIFT_MASK set. This is to allow the user to avoid 111 * indentation when Shift+Return is pressed. Other indenters may want 112 * to copy this behavior to provide a consistent experience to users. 113 * 114 * Params: 115 * view = a #GtkSourceView 116 * location = the location where @ch is to be inserted 117 * state = modifier state for the insertion 118 * keyval = the keyval pressed such as [const@Gdk.KEY_Return] 119 * 120 * Returns: %TRUE if indentation should be automatically triggered; 121 * otherwise %FALSE and no indentation will be performed. 122 */ 123 public bool isTrigger(View view, TextIter location, GdkModifierType state, uint keyval); 124 }